package de.hhbk.feedbackmodul.beans.viewscope;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;

import de.hhbk.feedbackmodul.beans.applicationscope.ApplicationManagerBean;
import de.hhbk.feedbackmodul.beans.sessionscope.SessionManagerBean;
import de.hhbk.feedbackmodul.entities.Survey;
import de.hhbk.feedbackmodul.util.SurveyStatusView;

public class SurveyOverviewViewBean {

	private ApplicationManagerBean masterBean;
	
	private SessionManagerBean sessionBean;
	
	private List<Survey> serveyList;
	
	private List<SurveyStatusView> GroupedSurveys;

	@PostConstruct
	public void init()
	{
		serveyList = masterBean.getSurveyList();
		GroupedSurveys = new ArrayList<SurveyStatusView>();
		SurveyStatusView actualSurveys = new SurveyStatusView();
		SurveyStatusView finishedSurveys = new SurveyStatusView();
		actualSurveys.setStatus("laufend");
		finishedSurveys.setStatus("abgeschlossen");
		for(Survey s : serveyList)
		{
			if(s.isStatus())
			{
				actualSurveys.getSurveys().add(s);
			}
			else
			{
				finishedSurveys.getSurveys().add(s);
			}
		}
		GroupedSurveys.add(actualSurveys);
		GroupedSurveys.add(finishedSurveys);
	}
	
	/* GETTER + SETTER */
	
	public List<Survey> getServeyList() {
		return serveyList;
	}

	public void setServeyList(List<Survey> serveyList) {
		this.serveyList = serveyList;
	}

	public ApplicationManagerBean getMasterBean() {
		return masterBean;
	}

	public void setMasterBean(ApplicationManagerBean masterBean) {
		this.masterBean = masterBean;
	}

	public SessionManagerBean getSessionBean() {
		return sessionBean;
	}

	public void setSessionBean(SessionManagerBean sessionBean) {
		this.sessionBean = sessionBean;
	}

	public List<SurveyStatusView> getGroupedSurveys() {
		return GroupedSurveys;
	}

	public void setGroupedSurveys(List<SurveyStatusView> groupedSurveys) {
		GroupedSurveys = groupedSurveys;
	}

	
}
